<?php	
	$path_one = 'admin/admin_project';
	$path_two = 'admin/car_set';
	$filename = 'admin/car_set';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
		
	$admin_obj = new admin();
	$user_info = $admin_obj->out_cookie();
	if($user_info['id']==1){		
		$result=$admin_obj->search_manage("id,account,name");
		$pid=request('pid',false,true,false,0);
	}else{
		$pid=$user_info['id'];
	}	    
    
	$project_id=request('prid',false,true,false,0);
	$data=array();
    //查询项目信息
    if($pid){
    	$project_obj=new project();
    	$project_ary=$project_ary=$project_obj->project_by_uid($pid);
    	if($project_ary && !$project_id){
    		$project_id=$project_ary[0]['id'];
    	}
    	
    	//非管理员账号
    	if($user_info['group']!=6){
    		$data['guest']=true;
    	}
    	//统计查询信息
    	$total_ary=$project_obj->get_record_date($pid,$project_id,$data);
    	
    	if($total_ary){    		
    		foreach($total_ary as $val){
    			$date_ary[$val['dates']][]=$val;
    		}
    	}
    }
    $type_ary=array(1=>'装车模式',2=>'计时模式',3=>'渣车模式',4=>'辅助装车');
?>
<script type="text/javascript" charset="utf-8">
	loader.file({
		skincss:['list']
	})	

	function getOut(type,date){				
		window.location.href="/handle.php?h=project/picout&type="+type+"&uid=<?php echo $pid;?>&pid=<?php echo $project_id?>&date="+date;
		return false;
    }	
</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?></div>
		<div class="main">

			<div class="sos_box">
				<form action="/admin/picdownload" id="search" method='get'>
		<?php 
		 if($user_info['id']==1){
		?>
				<span>项目经理：</span>
				    <select name='pid'>
					   <option value="">请选择</option>
					      <?php 
					      if($result){
					      foreach($result as $key=>$val){
                          ?>
                             <option value="<?php echo $val['id']?>" <?php if($val['id']==$pid){echo "selected";} ?>><?php echo $val['name']?></option>
                          <?php 
                             }
                          }
					      ?>					 
					</select>						
					<input class="button1" type="submit" value="搜索">
			<?php 
			}
			?>
					
					<font color="red">注意：</font> 导出图片链接文件后，请使用软件下载图片；系统根据情况会删除5天前的图片数据；请及时下载保存
				</form>
			</div>
			
			<style>
.dishes_top {
    width: 100%;
}
.dishes_top a{text-decoration: none;}
.dishes_top ul {
    float: left;
    width: 100%;
	margin-top:10px;
}
.dishes_top ul li {
    display: inline-block;
    padding: 0 5px;
}
.dishes_top ul li a {    
    display: block;
    font-size: 14px;
    height: 35px;
    line-height: 35px;
    width: 140px;
	background-color:#eeeeee;
    color: #454545;
    font-size: 14px;
	text-align: center;	
}
.dishes_top ul li a:hover {
    background-color: #79473a;
	color:#ffffff;
}
.dishes_top ul li a.hover {
    background-color: #79473a;
	color:#ffffff;
}			
			</style>

			<div class="dishes_top">
			 <?php 
			   if($project_ary){
			 ?>
			  <ul>
			    <?php 
			      foreach($project_ary as $val){
			    ?>				     		
				 <li><a <?php if($project_id==$val['id']){ ?>class="hover"<?php }?> href="/admin/picdownload?pid=<?php echo $pid?>&prid=<?php echo $val['id']?>"><?php echo $val['title']?></a></li>
				 <?php 
				 }
				 ?>			
			  </ul>	
			 <?php 
			 }
			 ?> 
			</div>			
			
			
		    <?php 
		     if(empty($pid)){
		    ?>			
			<table cellpadding="0" cellspacing="1" border="0" class="table" style="margin-top: 20px;">
				<tr>
					<td colspan="8">
						<div class="list_more">
							<font color="red">请选择相应项目项目经理！</font>
						</div>
					</td>
				</tr>					
			</table>
			<?php 
			 }
			?>				
			
			<?php 
			  if($total_ary){
			?>
			<table cellpadding="0" cellspacing="1" border="0" class="table" style="margin-top: 60px;">				    		
	            <tr>
					<th align="center">日期</th>
					<th align="center">模式</th>
					<th align="center">总数</th>
					<th align="center">操作</th>
				</tr>
				
				<?php
				     $_index=''; 						     		 				                 
                     foreach ($total_ary as $v){
				?>			
				<tr>
				    <?php 
				       if($_index!=$v['dates']){
				    ?>
					<td align="center" rowspan="<?php echo count($date_ary[$v['dates']]);?>"><?php echo $v['dates'];?></td>
					<?php
					$_index=$v['dates'];
					}
					?>
					<td align="center"><?php echo $type_ary[$v['type']];?></td>					
					<td align="center"><?php echo $v['sum'];?></td>
					<td align="center">
					      <input class="button1" type="button" value="导出" onclick="getOut(<?php echo $v['type'].',\''.$v['dates'].'\'' ?>)">
				</tr>	
				<?php 				  
				}
				?>										
			</table>				
			<?php 
			}
			?>
			
		    <?php 
		     if($pid && empty($total_ary)){
		    ?>			
			<table cellpadding="0" cellspacing="1" border="0" class="table" style="margin-top: 60px;">
				<tr>
					<td colspan="8">
						<div class="list_more">
							<font color="red">暂无数据 !!</font>
						</div>
					</td>
				</tr>					
			</table>
			<?php 
			 }
			?>					
			
			
		</div>
	</div>
</body>
</html>